/*
 * Javasript based on Functions(JBF) v1.03
 * 
 * Copyright(c) 2010, Fooxee (JA86.CN)
 *
 * JBF is licensed under the terms of the Open Source GPL 3.0(http://www.gnu.org/licenses/gpl.html) license. 
 * 
 * JBF's blog: http://www.cnblogs.com/JBF/
 * 
 * JBF's project: http://jbfproject.googlecode.com/
 *
 * Created by Fooxee. at 2010.03.30  mailTo:hjccjun@163.com
 */﻿
 
 
/*

#summary JBF 主文档.

= JBF =

对象:JBF

文件:JBF.js

描述:JBF库主文件.

|| [#Public_Config 配置项] || [#Public_Properties 属性] || [#Public_Methods 方法] || [#Public_Events 事件] ||

=== Public Config ===
公开配置

|| *名称* || *类型* || *描述* ||
|| cfg	|| type	||	desc ||

=== Public Properties ===
公开属性

|| *属性* || *类型* || *描述* ||
|| *version*	|| String	|| 当前JBF版本号 ||
|| *baseURL*	|| String	|| 相对于JBF主文件的路径 ||
|| *emptyFn*<br>*fn*	|| Function || 空函数 ||
|| screen || screen ||  ||
|| isOpera || Boolean || 浏览器验证 ||
|| isWebKit || Boolean ||  ||
|| isChrome || Boolean ||  ||
|| isSafari || Boolean ||  ||
|| isSafari2 || Boolean ||  ||
|| isSafari3 || Boolean ||  ||
|| isSafari4|| Boolean ||  ||
|| isIE || Boolean ||  ||
|| isIE6 || Boolean ||  ||
|| isIE7 || Boolean ||  ||
|| isIE8 || Boolean ||  ||
|| isGecko || Boolean ||  ||
|| isGecko2 || Boolean ||  ||
|| isGecko3 || Boolean ||  ||
|| isFF || Boolean ||  ||
|| isFF2 || Boolean ||  ||
|| isFF3 || Boolean ||  ||
|| isBorderBox || Boolean || 环境验证 ||
|| isLinux || Boolean ||  ||
|| isWindows || Boolean ||  ||
|| isMac || Boolean ||  ||
|| isAir || Boolean ||  ||


=== Public Methods ===
公开方法

*method*():void
描述.<br>
参数
	|| *参数名* || *值类型* || *描述* ||
	|| name 	|| type 	|| desc ||

*返回*:String desc <br>
*例子*
{{{
...


...	
}}}


=== Public Events ===
公开事件

|| *事件名* || *描述* || *回调参数* ||
|| event	|| 事件		|| this ||



*/

//兼容
window.undefined = window.undefined;

//JBF start
var JBF = window.JBF = function()
{
	//判断是否包含DOM接口
	if(JBF.Dom)
	{
		return JBF.Dom.apply(this, arguments);
	}
	else
	{
		return typeof arguments[0] =="string" ? document.getElementById(arguments[0]) : arguments[0];
	}
};
//JBF是否已初始化,没有则开始
if(!JBF.initialized){(function(){
	JBF.initialized=true;
	var toString = Object.prototype.toString,
	push = Array.prototype.push,
	slice = Array.prototype.slice,
	indexOf = Array.prototype.indexOf,
	ua = navigator.userAgent.toLowerCase(),
	check = function(r){return r.test(ua);},
	DOC = document,
	baseURL,
	isStrict = DOC.compatMode == "CSS1Compat",
	isOpera = check(/opera/),
	isChrome = check(/chrome/),
	isWebKit = check(/webkit/),
	isSafari = !isChrome && check(/safari/),
	isSafari2 = isSafari && check(/applewebkit\/4/),
	isSafari3 = isSafari && check(/version\/3/),
	isSafari4 = isSafari && check(/version\/4/),
	isIE = !isOpera && check(/msie/),
	isIE7 = isIE && check(/msie 7/),
	isIE8 = isIE && check(/msie 8/),
	isIE6 = isIE && !isIE7 && !isIE8,
	isGecko = !isWebKit && check(/gecko/),
	isGecko2 = isGecko && check(/rv:1\.8/),
	isGecko3 = isGecko && check(/rv:1\.9/),
	isFF = isGecko && check(/firefox/),
	isFF2 = isFF && check(/firefox\/2/),
	isFF3 = isFF && check(/firefox\/3/),
	isBorderBox = isIE && !isStrict,
	isWindows = check(/windows|win32/),
	isMac = check(/macintosh|mac os x/),
	isAir = check(/adobeair/),
	isLinux = check(/linux/),
	isSecure = /^https/i.test(window.location.protocol);
	
	//如果$或$$未使用,则使用它
	//保存一个$的早期的副本,如果有必要则交还$控制
	window._$=window.$;
	if(!window.$)
		window.$=window.JBF;
	else
		window.$$=window.JBF;
	
	//解决IE6不缓存背景图片,造成闪烁的BUG
	if(isIE6){try{
		DOC.execCommand("BackgroundImageCache", false, true);
	}catch(e){}};
	
	//获取JBF主文件相对路径
	if(document && document.getElementsByTagName)
	{
		var scripts = document.getElementsByTagName("script"),
			rePkg = /JBF\.js(\W|$)/i;
		for(var i = 0; i < scripts.length; i++)
		{
			var src = scripts[i].getAttribute("src");
			if(!src || baseURL){ continue; }
			var m = src.match(rePkg);
			if(m)
				baseURL=src.substring(0, m.index);
		}
	}
	//将Object 转换为类
	Object.prototype.toClass=function()
	{
		if(toString.apply(this)!='[object Object]')
			throw new Error('JBF ERROR:','数据类型不匹配!');

		var me = this,
			init= arguments[0] || me.init || function(){};
		
		me.init =typeof me.init == 'function' ? me.init : function(){};
		me.init.prototype=me;
		me.init.constructor=this;
		return me.init;
	}
	/*
	*apply*():Object
	把一个对象的所有属性复制到另一个对象中.<br>
	参数
		|| *参数名* || *值类型* || *描述* ||
		|| o 	|| Object 	|| 源对象 ||
		|| t 	|| Object 	|| 目标对象 ||
	
	*返回*:{String} 新的对象 <br>
	<hr>
	*/
	JBF.apply = function(t,o)
	{
		if(o && t && typeof o == 'object')
		{
			for(var p in o)
			{
				t[p] = o[p];
			}
		}
		return t;
	};
	
	JBF.apply(JBF,{	  
	version: 1.03,
	zIndex : 0,
	idSeed : 0,
	baseURL: baseURL,
	emptyFn: function(){},
	fn : function(){},
	
	//调试模式
	debugMod:2,
	//private 
	debug : function(e,mod)
	{
		JBF.debugMod=JBF.debugMod || 0;
		if(JBF.debugMod==0)
		{
			var putmsg	='JBF debug Error:';
				putmsg +='\n错误类型:'+e.name;
				putmsg +='\n错误行号:'+(e.lineNumber || e.number);
				putmsg +='\n详细信息:'+e.message;
			alert(putmsg);
		}
		else if(JBF.debugMod==1)
		{
			throw e;
		}
		//FF firebug
		else if(JBF.debugMod==2)
		{
			var putmsg	='JBF debug Error:';
				putmsg +='\n错误类型:'+e.name;
				putmsg +='\n错误行号:'+(e.lineNumber || e.number);
				putmsg +='\n详细信息:'+e.message;
			console.log(putmsg);
		}
	},
		
	/*
	*applyIf*():Object
	把一个对象的所有属性复制到另一个对象中,如果目标对象中不存在.<br>
	参数
		|| *参数名* || *值类型* || *描述* ||
		|| o 	|| Object 	|| 源对象 ||
		|| t 	|| Object 	|| 目标对象 ||
	
	*返回*:{String} 新的对象 <br>
	<hr>
	*/
	applyIf : function(t,o)
	{
		if(o && t && typeof o == 'object')
		{
			for(var p in o)
			{
				if(!JBF.isDefined(t[p]))
					t[p] = o[p];
			}
		}
		return t;
	},
	
	/*
	*createClass*():Function
	创建新类.<br>
	参数
		|| *参数名* || *值类型* || *描述* ||
		|| param(可选) 	|| Function || 可选方法(将重写init) ||
		|| param(可选) 	|| Object 	|| 类成员 ||
	
	*返回*:{Function} 新类 <br>
	*例子*
	{{{
	...
	//1.创建类 
	var cls=JBF.createClass(); 
	var sl=new cls(); 
	 
	//2.创建类 
	cls=JBF.createClass(function() 
	{ 
		alert('还没有成员'); 
	}); 
	sl=new cls(); 
	 
	//3.创建类 
	cls=JBF.createClass({ 
		say:function() 
		{ 
		  alert('hello'); 
		} 
	}); 
	sl=new cls(); 
	sl.say(); 
	 
	 
	//4.创建附加类 
	var obj={ 
		init:function() 
		{ 
				this.msg='我是构造方法'; 
		}, 
		say:function() 
		{ 
		  alert(this.msg); 
		} 
	} 
	cls=JBF.createClass(obj); 
	sl=new cls(); 
	sl.say(); 
	 
	//5.创建附加类,使用新的构造方法 
	cls=JBF.createClass(function() 
	{ 
		this.msg='我是新的构造方法'; 
	},obj); 
	sl=new cls(); 
	sl.say();
	...
	}}}
	<hr>
	*/
	createClass : function()
	{
		var o;
		if(JBF.isFunction(arguments[0]))
		{
			o=arguments[1] || {};
			return o.toClass(arguments[0],arguments[1]);
		}
		else
		{
			o=arguments[0] || {};
			return o.toClass();	
		}
	},
	
	/*
	*extend*(Function sp,Object o):Object
	继承(需要重写).<br>
	参数
		|| *参数名* || *值类型* || *描述* ||
		|| sp 	|| Function || 父类 ||
		|| o 	|| Object 	|| 重写对象 ||
	
	*返回*:{Function} 子类 <br>
	<hr>
	*/
	extend : function(sp,o)
	{
		sp=JBF.isFunction(sp) ? sp : this;
		o=JBF.isObject(o) ? o : {};
		var cinit=JBF.isFunction(o.init) ? o.init : JBF.emptyFn,
		b=JBF.apply(o,sp.prototype);
		b.init=cinit;
		b.superclass=new sp();
		var sb=JBF.createClass(b);
		return sb;
	},
	/*
	
	jQuery.extend = jQuery.fn.extend = function() {
	// copy reference to target object
	var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;

	// Handle a deep copy situation
	if ( typeof target === "boolean" ) {
		deep = target;
		target = arguments[1] || {};
		// skip the boolean and the target
		i = 2;
	}

	// Handle case when target is a string or something (possible in deep copy)
	if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
		target = {};
	}

	// extend jQuery itself if only one argument is passed
	if ( length === i ) {
		target = this;
		--i;
	}

	for ( ; i < length; i++ ) {
		// Only deal with non-null/undefined values
		if ( (options = arguments[ i ]) != null ) {
			// Extend the base object
			for ( name in options ) {
				src = target[ name ];
				copy = options[ name ];

				// Prevent never-ending loop
				if ( target === copy ) {
					continue;
				}

				// Recurse if we're merging object literal values or arrays
				if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
					var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
						: jQuery.isArray(copy) ? [] : {};

					// Never move original objects, clone them
					target[ name ] = jQuery.extend( deep, clone, copy );

				// Don't bring in undefined values
				} else if ( copy !== undefined ) {
					target[ name ] = copy;
				}
			}
		}
	}

	// Return the modified object
	return target;
};

	*/
	
	/*
	*each*(Array|Object o,Function fn,Object scope):void
	遍历对象.<br>
	参数
		|| *参数名* || *值类型* || *描述* ||
		|| o 			|| Object 	|| 要遍历的对象  ||
		|| fn 			|| Function	|| 处理遍历的回调函数<br>*fn*(this,v,i,list) ||
		|| scope(可选)	|| Object	|| 引用对象 ||
	
	*返回*:{void} <br>
	*例子*
	{{{
	...
	//数组的遍历 
	var arr=[1,2,3,3,5,6];  
	JBF.each(arr,function(v,i,list) 
	{ 
		alert(v);//依次弹出1,2,3,3,5,6 
	}); 
	//JSON的遍历 
	var json={h:'hello',w:'world'}; 
	var s=''; 
	JBF.each(json,function(v,i,list) 
	{ 
		s+=list[v]+' '; 
	}); 
	alert(s);//弹出"hello world " 
	 
	//带引用对象的遍历 
	//构造一个类 
	var samp=JBF.createClass({ 
		add:function(n) 
		{ 
				alert(n+1);//每个参数加1并弹出 
		} 
	}); 
	 
	var sf=new samp(); 
	JBF.each(arr,function(v,i,list) 
	{  this.add(v);//依次弹出2,3,4,5,6,7 
	},sf);
	...
	}}}
	<hr>
	*/
	each : function(o,fn,scope)
	{
		var i=0,n,fn=fn||JBF.emptyFn;
		if(o.length)
		{
			for( ; i<o.length ;)
				fn.call(scope||this,o[i++], i-1, o);
		}
		else 
		{
			for(n in o)
				if(o.hasOwnProperty(n)) fn.call(scope||this,n, i++, o);
		}
	},
	
	/*
	*toArray*(Object o,Int i, Int l):Array
	将对象转换为真实的数组.<br>
	参数
		|| *参数名* || *值类型* || *描述* ||
		|| o		|| Object	|| 对象 ||
		|| i(可选) 	|| Int		|| 截取数组的开始索引,默认为0 ||
		|| l(可选) 	|| Int 		|| 截取数组的长度,默认为0 ||
	
	*返回*:{Array} 数组 <br>
	<hr>
	*/
	toArray : function()
	{
		 return isIE ?
			 function(o, i, l)
			 {
				 var res = [];
				 for(var x = 0, len = o.length; x < len; x++)
				 {
					 res.push(a[x]);
				 }
				 return res.slice(i || 0, l || res.length);
			 } :
			 function(o, i, l){
				 return slice.call(this, i || 0, l || o.length);
			 }
	 }(),
	
	/*
	*len*(Array|String|Object o):Int
	计算对象长度(字符串则汉字为两字节).<br>
	参数
		|| *参数名* || *值类型* || *描述* ||
		|| o 	|| Object 	|| 对象 ||
	
	*返回*:{Int} 对象长度 <br>
	<hr>
	*/
	len : function(o)
	{
		var i,sum=0;
		if(this.isObject(o))
		{
			if(this.isNumber(o.length))
			{
				return 	o.length;
			}
			else
			{
				this.each(o,function(k,i)
				{
					sum=i;
				});
				return sum+1;
			}
			
		}
		else if(this.isString(o))
		{
			for(i=0;i<o.length;i++)
			{
				if ((o.charCodeAt(i)>=0) && (o.charCodeAt(i)<=255))
					sum=sum+1;
				else
					sum=sum+2;
			}
			return sum;
		}
	},
	
	/*
	*createRequest*():Object
	创建XMLHttpRequest对象.<br>
	*返回*:{Object} 新的对象 <br>
	*/
	createRequest : function()
	{
		try{ return new window.XMLHttpRequest(); }
		catch(e){
		try{ return new window.ActiveXObject("Microsoft.XMLHTTP"); }
		catch(e){ return new window.ActiveXObject("Msxml2.XMLHTTP"); }}
	},
	
	
	//private
	modules:{},
	loadedScripts:[],
	
	/*
	*provide*(Array|String p,String src):void
	JBF模块支持.JBF默认核心配置文件core/config.js
	<br>
	*参数*
	|| 参数名 || 参数类型 || 描述 ||
	|| p || Array|String || 模块名或模块名数组 ||
	|| src || String || 模块文件路径(相对于主文件) ||
	
	*返回*:{void}
	<br>
	*例子*
	{{{
	...
	//单个支持
	JBF.provide('JBF.Dom','core/Dom.js');
	//多个支持
	JBF.provide(['JBF.Dom','JBF.dom'],'core/Dom.js');
	...
	}}}
	
	<hr>
	*/
	provide:function(p,src)
	{
		if(!(this.isString(p) || this.isArray(p)) || !this.isString(src))
		{
			this.debug(new Error(10,'include error: 模块注册错误'));
			return;	
		}
		if(this.isArray(p))
		{
			this.each(p,function(v,i,list)
			{
				if(this.isString(v))
				{
					this.modules[v]=src;
				}
			},this);
		}
		else
		{
			JBF.modules[p]=src;
		}
	},
	
	//private
	//载入脚本
	evalScript : function()
	{
		return function(src){
			try
			{
				var xhr = JBF.createRequest();
				xhr.open("GET", src, false);
				xhr.send();
				eval(xhr.responseText);
			}
			catch(e)
			{
				try{
					var script=document.createElement("script");   
					script.type='text/javascript';  
					script.src=scr;
					var head=document.getElementsByTagName("head")[0];
					head.appendChild(script);
				}catch(ee){}
			}	
		}
	}(),
	
	//private
	loadScript:function(src,mod,n)
	{
		var isReturn=false;
		if(mod)
		{
			this.each(this.loadedScripts,function(v,i,list)
			{
				if(v==src)
					isReturn=true;
			},this);
		}
		if(isReturn)
			return;
		
		this.evalScript(src);
	},
	
	/*
	*inc*(String n,Boolean mod):void
	调用JBF模块以便使用.<br>
	*incIf*(String n):void
	调用JBF模块以便使用,如果未加载.<br>
	*参数*
	|| 参数名 || 参数类型 || 描述 ||
	|| n || String || 模块名,支持像这样的通配符号*JBF.{{{ * }}} * ||
	|| mod || Boolean || 是否重复加载文件,默认true ||
	
	*返回*:{void}
	<br>
	*例子*
	{{{
	...
	//原始调用
	JBF.inc('JBF.Dom');
	JBF.inc('JBF.Dom',false);

	//判断调用
	JBF.incIf('JBF.*');
	...
	}}}
	
	<hr>

	*/
	using:function(n,mod)
	{
		if(!this.isString(n))
		{
			return;
		}
		var arr=n.split('.*');
		
		if(this.len(arr)==1)
		{
			var s=this.modules[arr[0]];
			this.loadScript(baseURL+s,mod,n);
			return;
		}
		else if(this.len(arr)==2)
		{
			this.each(this.modules,function(v,i,list)
			{
				if(v.indexOf(arr[0])==0)
				{
					var s=list[v];
					if(this.isString(s))
						this.loadScript(baseURL+s,mod,n);
					else
						this.debug(new Error(10,'include error: ['+n+'] 未定义'));
				}
			},this);
		}
		else
			this.debug(new Error(10,'include error: ['+n+'] 未定义'));
	},
	usingIf:function(n)
	{
		this.using(n,true);
	},
	
	
	
	/*
	*验证函数*
	
	|| *函数* || *描述* ||
	|| *isEmpty*(Object v,Object allowBlank):Boolean<br>*isNull*(Object v):Boolean || 验证对象是否为空 ||
	|| *isArray*(Object v):Boolean || 是否为数组 ||
	|| *isDate*(Object v):Boolean || 是否为日期 ||
	|| *isObject*(Object v):Boolean || 是否为对象 ||
	|| *isFunction*(Object v):Bollean<br>*isFn*(Object v):Boolean || 是否为函数 ||
	|| *isNumber*(Object v):Bollean<br>*isNum*(Object v):Boolean || 是否为数字 ||
	|| *isString*(Object v):Bollean<br>*isStr*(Object v):Boolean || 是否为字符串 ||
	|| *isBool*(Object v):Bollean<br>*isBoolean*(Object v):Boolean || 是否为布尔 ||
	|| *isPrimitive*(Object v):Boolean || 是否为原型对象(字符串,数字,布尔) ||
	|| *isElement*(Object v):Boolean || 是否为DOM元素 ||
	|| *isXMLDoc*(Object v):Boolean || 是否为XML模型 ||
	|| *isDefined*(Object v):Boolean || 是否定义 ||
	|| *isEmail*(String v):Boolean || 是否为电子邮箱 ||
	|| *isURL*(String v):Boolean || 是否为URL ||

	
	*/
	
	//是否为空
	isEmpty : function(v, allowBlank)
	{
		return v === null || v === undefined || ((JBF.isArray(v) && !v.length)) || (!allowBlank ? v === '' : false);
	},
	//是否为空
	isNull:function(v)
	{
		return v === null || v === undefined ||  v === '';
	},
	
	//是否是数组
	isArray : function(v)
	{
		return toString.apply(v) === '[object Array]';
	},
	//是否是数组
	isArr : function(v)
	{
		return toString.apply(v) === '[object Array]';
	},

	//是否是日期
	isDate : function(v)
	{
		return toString.apply(v) === '[object Date]';
	},
	
	//是否是对象
	isObject : function(v)
	{
		return typeof v=='object';
	},
	//是否是对象
	isObj : function(v)
	{
		return typeof v=='object';
	},

	//是否是基本类型(不可再细分的)
	isPrimitive : function(v)
	{
		return JBF.isString(v) || JBF.isNumber(v) || JBF.isBoolean(v);
	},
	
	//是否是函数
	isFunction : function(v)
	{
		return toString.apply(v) === '[object Function]';
	},
	//是否是函数
	isFn : function(v)
	{
		return toString.apply(v) === '[object Function]';
	},

	
	//是否是数字
	isNumber : function(v)
	{
		return typeof v === 'number' && isFinite(v);
	},
	//是否是数字
	isNum : function(v)
	{
		return typeof v === 'number' && isFinite(v);
	},
	
	
	//是否是字符串
	isString : function(v)
	{
		return typeof v === 'string';
	},
	//是否是字符串
	isStr : function(v)
	{
		return JBF.isString(v);
	},
	
	
	//是否是布尔值
	isBoolean : function(v)
	{
		return typeof v === 'boolean';
	},
	//是否是布尔值
	isBool : function(v)
	{
		return JBF.isBoolean(v);
	},
	
	//是否是DOM元素
	isDom : function(v)
	{
		return v && v.nodeType==9;
	},
	//是否是DOM元素
	isElement : function(v)
	{
		return v && v.nodeType==1;
	},
	
	//是否是XML文档
	isXMLDoc: function(v)
	{
		return v.documentElement && !v.body || v.tagName && v.ownerDocument && !v.ownerDocument.body;
	},
	
	//是否定义
	isDefined : function(v)
	{
		return typeof v !== 'undefined';
	},
	
	//是否是电子邮箱
	isEmail:function(v)
	{
		return /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,4}$/.test(v);
	},
	isURL : function(s)
	{
		var m = "^((https|http|ftp|rtsp|mms)?://)" 
		+ "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp user@ 
		+ "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IPv4
		+ "|" 
		+ "([0-9a-z_!~*'()-]+\.)*" // 域名- www. 
		+ "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名 
		+ "[a-z]{2,6})" 
		+ "(:[0-9]{1,4})?" // 端口- :80 
		+ "((/?)|" // 无文件名 /?
		+ "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$"; 
		return new RegExp(m).test(s);
	},
	
	//浏览器相关
	isOpera : isOpera,
	isWebKit : isWebKit,
	isChrome : isChrome,
	isSafari : isSafari,
	isSafari2 : isSafari2,
	isSafari3 : isSafari3,
	isSafari4 : isSafari4,
	isIE : isIE,
	isIE6 : isIE6,
	isIE7 : isIE7,
	isIE8 : isIE8,
	isGecko : isGecko,
	isGecko2 : isGecko2,
	isGecko3 : isGecko3,
	isFF : isFF,
	isFF2 : isFF2,
	isFF3 : isFF3,
	isBorderBox : isBorderBox,
	isLinux : isLinux,
	isWindows : isWindows,
	isMac : isMac,
	isAir : isAir,
	screen : window.screen,
	
	//private
	_readyCache : [],
	_readyTimer : false,
	
	isReady : false,
	/*
	*ready*(Function handler):void
	等待DOM加载完成,等效于onload,推荐使用.<br>
	*参数*
	|| 参数名 || 参数类型 || 描述 ||
	|| handler || Function || 加载完成后要执行的函数 ||
	
	*返回*:{void}
	<br>
	*例子*
	{{{
	...
	
	JBF.ready(function()
	{
	   alert('ready');
	});
	...
	}}}
	
	<hr>
	*/
	ready : function(handler)
	{
		this.pollReady();
		if(!JBF.isFunction(handler))
		{
			return;
		}
		if(this.isReady)
		{
			handler();
		}
		else
		{
			this._readyCache.push(handler);	
		}
	},
	//private
	pollReady : function()
	{
		if(arguments.callee.one)
		{
			return;
		}
		arguments.callee.one = true;
		
		//是否为顶层页面
		//if(self !== self.top) return;
		
		//ie
		if(JBF.isIE)
		{
			(function(){
				if (JBF.isReady) return;
				try
				{document.documentElement.doScroll("left");} catch(e)
				{
					JBF._readyTimer=setTimeout(arguments.callee,0);
					return;
				}
				JBF.ready();
			})();
			document.onreadystatechange = function()
			{
				if (document.readyState === 'complete')
				{
					document.onreadystatechange = null;//清除加载函数
					JBF.fireReady();
				}
			};
		}
		else //outher
		{
			try{
			document.addEventListener("DOMContentLoaded", function()
			{
				document.removeEventListener( "DOMContentLoaded", arguments.callee, false );
				JBF.fireReady();
			}, false);
			}catch(e){}
		}
	},
	fireReady : function()
	{
		JBF.isReady=true;
		JBF.each(JBF._readyCache,function(v,i,list)
		{
			v.call(window,JBF);
		});
		if (JBF._readyTimer){window.clearTimeout(JBF._readyTimer);}
	}
	
	});
	
	//载入模块配置文件
	JBF.evalScript(baseURL+'base/Config.js');

})();};
	














